<?php

class App_Methods_Request_AddUserGroup {

  /**
   *
   * @var App_Methods_Data_App
   */
  public $app;
	public $name;
	public $nameEn;

  public function __construct($params) {
    $this->app = new App_Methods_Data_App($params->app);
    $this->name = $params->name;
    $this->nameEn = $params->nameEn;
  }

  public function process() {
    if (!Core_Auth::getInstance()->getUser()->isAdmin())
    	throw new App_Exception_App(4000);
    
    $userGroup = new UserGroups();
    $userGroup->setName($this->name);
    $userGroup->setNameEn($this->nameEn);
    $userGroup->setBasic(0);
    $userGroup->save();
    
    return new App_Methods_Response_AddUserGroup($userGroup, true);
  }

}